package cn.com.huzo.repository.trade.impl;

import cn.com.huzo.model.entities.trade.MasterProductionScheduleLinesTrackEntity;
import huzofw.repository.impl.GenericRepositoryImpl;
import org.springframework.stereotype.Repository;
import cn.com.huzo.repository.trade.MasterProductionScheduleLinesTrackRepository;
import huzofw.repository.impl.MyBatisDaoUtils;
import java.sql.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 产品计划跟踪项目数据访问对象接口
 *
 * @author 吴旭
 */
@Repository("MasterProductionScheduleLinesTrackRepository")
public class MasterProductionScheduleLinesTrackRepositoryImpl extends GenericRepositoryImpl<MasterProductionScheduleLinesTrackEntity, String>
        implements MasterProductionScheduleLinesTrackRepository {

    private final String namespace = "cn.com.huzo.repository.trade.MasterProductionScheduleLinesTrackRepository";

    /**
     * 构造函数,设置the instance to ProductRepositoryImpl.class.
     */
    public MasterProductionScheduleLinesTrackRepositoryImpl() {
        super(MasterProductionScheduleLinesTrackEntity.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer insert(List<MasterProductionScheduleLinesTrackEntity> itemList) {
        return getSqlSession().insert(MyBatisDaoUtils.getMapperQueryId(
                namespace, "insert"), itemList);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer syncUpdateTrackItem(Long headerId, String parentLinesId,
            Long itemId, Date plan, Date actual, String status, Long updatedBy) {
        Map<String, Object> criterion = new HashMap();
        criterion.put("HeaderId", headerId);
        criterion.put("ParentLinesId", parentLinesId);
        criterion.put("ItemId", itemId);
        criterion.put("Plan", plan);
        criterion.put("Actual", actual);
        criterion.put("Status", status);
        criterion.put("UpdatedBy", updatedBy);

        return getSqlSession().update(MyBatisDaoUtils.getMapperQueryId(
                namespace, "syncUpdateTrackItem"), criterion);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Integer deleteByParentLinesId(String parentLinesId) {
        return getSqlSession().delete(MyBatisDaoUtils.getMapperQueryId(
                namespace, "deleteByParentLinesId"), parentLinesId);
    }
}
